<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../base/taglibs.jsp" %>
<ssm:overwrite name="style">
<link rel="stylesheet" href="${STATIC}/css/select2.css" />
</ssm:overwrite>
<ssm:overwrite name="context">
<form  class="form-horizontal"  id="validation-form" action="edit" method="POST">
	<div class="widget-body">
		<div class="widget-main">
			<div class="step-content row-fluid position-relative">
			<h3 class="lighter block green">${WEB_TITLE}</h3>
				<div class="form-group">
					<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="modules">modules:</label>
					<div class="col-xs-12 col-sm-9">
						<div class="clearfix">
							<input  type="text" name="modules" value="${userrule.modules}" class="col-xs-12 col-sm-6" />
						</div>
					</div>
				</div>
				<div class="space-2"></div>
				<div class="form-group">
					<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="type">type:</label>

					<div class="col-xs-12 col-sm-9">
						<div class="clearfix">
							<input  type="text" name="type" value="${userrule.type}" class="col-xs-12 col-sm-4" />
						</div>
					</div>
				</div>
				<div class="space-2"></div>
				<div class="form-group">
					<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="link">link:</label>

					<div class="col-xs-12 col-sm-9">
						<div class="clearfix">
							<input  type="text" name="link" value="${userrule.link}" class="col-xs-12 col-sm-4" />
						</div>
					</div>
				</div>
				<div class="hr hr-dotted"></div>
				<div class="form-group">
					<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="title">title:</label>

					<div class="col-xs-12 col-sm-9">
						<div class="clearfix">
							<input type="text" name="title" value="${userrule.title}" class="col-xs-12 col-sm-5" />
						</div>
					</div>
				</div>
				<div class="space-2"></div>
				<div class="form-group">
					<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="status">status:</label>
					<div class="col-xs-12 col-sm-9">
						<select id="status" class="select2" type="text" name="status" value="${userrule.status}">
							<option value="-1">删除</option>
							<option value="0">关闭</option>
							<option value="1">开启</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="rank">rank:</label>

					<div class="col-xs-12 col-sm-9">
						<div class="clearfix">
							<input type="text" name="rank" value="${userrule.rank}" class="col-xs-12 col-sm-8" />
						</div>
					</div>
				</div>
				<div class="space-2"></div>
				<div class="form-group">
					<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="url">createtime:</label>
					<div class="col-xs-12 col-sm-9">
						<div class="clearfix">
							<input type="text" name="createtime" value="${userrule.createtime}" class="col-xs-12 col-sm-8" ReadOnly/>
						</div>
					</div>
				</div>
				<div class="hr hr-dotted"></div>
				<div class="form-group">
					<label class="control-label col-xs-12 col-sm-3 no-padding-right">pid</label>
					<div class="col-xs-12 col-sm-9">
						<div>
							<label>
								<input type="text" name="pid" value="${userrule.pid}" />
							</label>
						</div>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="comment">description</label>

					<div class="col-xs-12 col-sm-9">
						<div class="clearfix">
							<textarea class="input-xlarge" type="text" name="description" value="${userrule.description}">${userrule.description}</textarea>
						</div>
					</div>
				</div>
				<div class="form-group">
					<c:if test="${userrule!=null}">
					<input type="hidden" name="id" value="${userrule.id}">
					</c:if>
				</div>
			<div class="row-fluid wizard-actions">
				<button class="btn btn-success btn-next"  data-last="Finish ">
					提交
					<i class="icon-arrow-right icon-on-right"></i>
				</button>
			</div>	
			</div>
		</div><!-- /widget-main -->
	</div><!-- /widget-body -->
</form>
</ssm:overwrite>
<ssm:overwrite name="script">
	<script src="${STATIC}/js/jquery.validate.min.js"></script>
	<script src="${STATIC}/js/jquery.maskedinput.min.js"></script>
		<!-- inline scripts related to this page -->
		<script type="text/javascript">
			jQuery(function($) {
				
				//自动选中数据中的选项
				$('option[value="${userrule.status}"]').attr("selected","selected");
				
				$('#validation-form').validate({
					errorElement: 'div',
					errorClass: 'help-block',
					focusInvalid: false,
					rules: {
						modules: {
							required: true
						},
						type: {
							required: true,
							//minlength: 5
						},
						link: {
							required: true,
							//minlength: 5,
							//equalTo: "#password"
						},
						title: {
							required: false
						},
						status: {
							required: true,
							//phone: 'required'
						},
						pid: {
							required: true
						}
					},
			
					messages: {
						modules: {
							required: "modules为必填."
							//,email: "Please provide a valid email."
						},
						type: {
							required: "type为必填."
							//minlength: "Please specify a secure password."
						},
						link: "Please provide a link",
						title: "Please provide a title",
						status: "Please provide a status",
						pid: "Please provide a pid"
					},
					invalidHandler: function (event, validator) { //display error alert on form submit   
						$('.alert-danger', $('.login-form')).show();
					},
			
					highlight: function (e) {
						$(e).closest('.form-group').removeClass('has-info').addClass('has-error');
					},
			
					success: function (e) {
						$(e).closest('.form-group').removeClass('has-error').addClass('has-info');
						$(e).remove();
					},
					errorPlacement: function (error, element) {
						if(element.is(':checkbox') || element.is(':radio')) {
							var controls = element.closest('div[class*="col-"]');
							if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
							else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
						}
						else if(element.is('.select2')) {
							error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
						}
						else if(element.is('.chosen-select')) {
							error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
						}
						else error.insertAfter(element.parent());
					},
					submitHandler: function (form) {
						form.submit(); 
					},
					invalidHandler: function (form) {
					}
				});
			})
		</script>
</ssm:overwrite>
<jsp:include page="../base/base.jsp"></jsp:include>